import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpProvider } from '../../providers/http/http';
import { StorageProvider } from '../../providers/storage/storage';
import { DialogProvider } from '../../providers/dialog/dialog';
/**
 * Generated class for the AssistantfixededitPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-assistantfixededit',
  templateUrl: 'assistantfixededit.html',
})
export class AssistantfixededitPage {

  	/**
	 * 输入界面控制
	 */
	inputSelectView = {
		applyoaminDate: '',
		applyoamaxDate: '',
  }
  
  /**
	 * 输入界面控制
	 */
  inputViewModel = {
    code: '', //资产编码：
    name: '', //资产：
    guiitem: new Object(), //资产归属：
    depart: new Object(), //管理部门：
    miao: '', //资产描述：
    gui: '', //规格程式：
    unit: '', //单位：
    number: '', //数量：
    gen: '', //原值：
    zan: '', //残值：
    first: '', //首次购置日期：
    fen: '', //资产分类：
    kuai: '', //会计核算分类：
    addgen: '', //增加原因：
    jiuma: '', //折旧码：
    jiufirst: '', //折旧计算开始日期：
    jiuyear: '', //折旧年限年：
    jiumonth: '', //折旧年限月：
    alljiuyear: '', //年初累计折旧：
    nowjiuyear: '', //当年记账折旧：
    nowjiumonth: '', //当月记账折旧：
    alljiu: '', //累计折旧：
    address: '', //所在地点：
    iszhang: '', //是否在账：
    user: new Object(), //使用人：
    usedepart: new Object(), //使用部门：
    userdepart: new Object(), //部门负责人：
    note: '', //备注：
  }

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public http: HttpProvider,
    public storage: StorageProvider,
    public dialog: DialogProvider) {
      this.inputViewModel.guiitem = new Object();
      this.inputViewModel.depart = new Object();
      this.inputViewModel.user = new Object();
      this.inputViewModel.usedepart = new Object();
      this.inputViewModel.userdepart = new Object();
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad AssistantfixededitPage');
  }
//初始化选择公司
applycompanyselect() {
  //共通弹出
  let data = new Object();
  data['selectitem'] = this.inputViewModel.guiitem;
  data['multiselect'] = false; //false 单选 true 多选
  let opts = new Object();
  this.dialog.showModal("ModalcompanyselectPage", data, opts).then(success => {
    //界面关闭的时候
    if(success) {
      let result = success['result'];
      this.inputViewModel.guiitem = result[0];
    }
  });
}
//初始化选择部门
applydepartselect(type) {
  //共通弹出
  let data = new Object();
  if(type == 1)
    data['selectitem'] = this.inputViewModel.depart;
  if(type == 2)
    data['selectitem'] = this.inputViewModel.usedepart;
  data['multiselect'] = false; //false 单选 true 多选
  let opts = new Object();
  this.dialog.showModal("ModaldepartselectPage", data, opts).then(success => {
    //界面关闭的时候
    if(success) {
      let result = success['result'];
      if(type == 1)
        this.inputViewModel.depart = result[0];
      if(type == 2)
        this.inputViewModel.usedepart = result[0];
    }
  });
}
//初始化选择用户
applyapplymemberselect(type) {
  //共通弹出
  let data = new Object();
  if(type == 1)
    data['selectitem'] = this.inputViewModel.user;
  if(type == 2)
    data['selectitem'] = this.inputViewModel.userdepart;

  data['multiselect'] = false; //false 单选 true 多选
  let opts = new Object();
  this.dialog.showModal("ModaluserselectPage", data, opts).then(success => {
    //界面关闭的时候
    if(success) {
      let result = success['result'];
      if(type == 1)
        this.inputViewModel.user = result[0];
      if(type == 2)
        this.inputViewModel.userdepart = result[0];
    }
  });
}
}
